
#import "PostLoginRequest.h"

@implementation PostLoginRequest

//
// user name
//
@synthesize userName														= _userName;

//
// password
//
@synthesize password														= _password;

//
// captcha
//
@synthesize captcha															= _captcha;

//
// init
//
- (id)init
{
	//
	// call super
	//
	self																	= [super init];
	if(!self)
		return nil;
	
	self.relPath															= @"takelogin.php";
	
	return self;
}

//
// dealloc
//
- (void)dealloc
{
	self.userName															= nil;
	self.password															= nil;
	self.captcha															= nil;
	
	[super dealloc];
}

//
// setup request
//
- (void)setupRequest
{
	//
	// call super
	//
	[super setupRequest];
	
	//
	// setup post data
	//
	NSString* postFormat													= @"login_type=email&username=%@&password=%@&captcha=%@";
	NSString* userName														= [self.userName encodeURL:NSUTF8StringEncoding];
	NSString* password														= [self.password encodeURL:NSUTF8StringEncoding];
	NSString* captcha														= [self.captcha encodeURL:NSUTF8StringEncoding];
	NSString* postString													= [NSString stringWithFormat:postFormat, userName, password, captcha];
	char const* postString8													= [postString UTF8String];
	self.postData															= [NSData dataWithBytes:postString8 length:strlen(postString8)];
}

@end
